import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { useI18n } from '/@/hooks/web/useI18n';

const { t } = useI18n();

export function reportColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.project.projectReport.templateName'),
      dataIndex: 'reportTemplateName',
      width: 200,
      align: 'center',
      fixed: 'left',
    },
    {
      title: t('routes.project.projectReport.templateCode'),
      dataIndex: 'projectType',
      width: 120,
      align: 'center',
    },
    {
      title: t('routes.project.projectReport.templateType'),
      dataIndex: 'reportTemplateAbout',
      width: 120,
      align: 'center',
    },
    {
      title: t('routes.project.projectReport.creator'),
      dataIndex: 'founderName',
      width: 120,
      align: 'center',
    },
  ];
}

export const searchProjectReportFormSchema: FormSchema[] = [
  {
    field: 'reportTemplateName',
    label: t('routes.project.projectReport.templateName'),
    component: 'Input',
    componentProps: {
      placeholder: t('routes.project.projectReport.templateNamePlaceholder'),
    },
    colProps: { span: 8 },
  },
  {
    field: 'projectType',
    label: t('routes.project.projectReport.templateCode'),
    component: 'Input',
    componentProps: {
      placeholder: t('routes.project.projectReport.templateCodePlaceholder'),
    },
    colProps: { span: 8 },
  },
];

export const ProjectReportFormSchema: FormSchema[] = [
  {
    field: 'reportTemplateName',
    label: t('routes.project.projectReport.templateName'),
    component: 'Input',
    required: true,
    defaultValue: '',
    componentProps: {
      placeholder: t('routes.project.projectReport.templateNamePlaceholder'),
    },
  },
  {
    field: 'projectType',
    label: t('routes.project.projectReport.templateCode'),
    component: 'Input',
    required: true,
    defaultValue: '',
    componentProps: {
      placeholder: t('routes.project.projectReport.templateCodePlaceholder'),
    },
  },
  {
    field: 'reportTemplateAbout',
    label: t('routes.project.projectReport.templateType'),
    component: 'ApiSelect',
    required: true,
    defaultValue: undefined,
    componentProps: {
      placeholder: t('routes.project.projectReport.templateTypePlaceholder'),
    },
  },
  {
    label: t('routes.project.projectReport.columnName'),
    field: 'reportTemplateListName',
    slot: 'reportTemplateListName',
    defaultValue: [],
    component: 'Input',
    show: (record) => {
      return (
        record.values.reportTemplateAbout === 'project' ||
        record.values.reportTemplateAbout === 'task' ||
        record.values.reportTemplateAbout === 'work'
      );
    }, // 模板类型为项目、任务、工作项时显示
  },
];
